const state = {
  typeList: [],
  typeInfo: {},
}

const mutations = {
  // 存储类别列表
  GETTYPE(state, value) {
    state.typeList = value
  },
  // 存储类型详情
  GETTYPEINFO(state, value) {
    state.typeInfo = value
  },
}

const actions = {
  // 根据分类id获取该分类下所有类型车
  async getType({ commit }, payload) {
    const ret = await reqTypeList(payload)
    commit('GETTYPE', ret.data)
  },
  // 根据类别id获取该类型车的信息
  async getTypeInfo({ commit }, payload) {
    const ret = await reqTypeInfo(payload)
    commit('GETTYPEINFO', ret.data)
  },
}

//计算属性
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
}
